@extends('admin.layout.layout')
@section('title','商品详情')
@section('con')
        <div id="page-wrapper">
            <div class="row">
                <div ass="col-lg-12">
                    <h1 class="page-header">
                   @section('head')     
                    商品详情
                    @show


                    </h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            商品详情
                        </div>
                        <!-- /.panel-heading -->
                        
                        <div class="panel-body">
                            <div class="dataTable_wrapper">
                                 <div id="dataTables-example_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
                                    <div class="row">
                        
                                <div class="row"><div class="col-sm-12"><table id="dataTables-example" class="table table-striped table-bordered table-hover dataTable no-footer" role="grid" aria-describedby="dataTables-example_info">
                                    <thead>
                                        <tr role="row">
                                        <th>商品id</th>
                                        <th>商品名</th>
                                        <th>商品类别</th>
                                        <th>商品价格</th>
                                        <th>库存</th>
                                        <th>销量</th>
                                
                                        <th>商品图片</th>
                                        
                                        <th>商品状态</th>
                                        <th>上传时间</th>
                                        
                                        <th>操作</th></tr>
                                    </thead>
                                    <tbody>
                                                                        
                                            
                                    <tr class="gradeA odd" role="row">
                                            <td class="sorting_1">{{$good->gid}}</td>
                                            <td>{{$good->gname}}</td>
                                            <td>{{$good->tname}}</td>
                                            
                                            <td class="center">{{$good->price}}</td>
                                            <td class="center">{{$good->cnt}}</td>
                                            <td class="center">{{$good->scnt}}</td>
                                            <td class="center"><img src="{{asset($good->gpic)}}" width="100px"></td>
                                            
                                            <td class="center sa">{{$sta[$good->status]}}</td>
                                            <td class="center">{{date('Y-m-d H:i:s',$good->ctime)}}</td>

                                            <td class="center"><a href="{{url('/admin/good/edit?gid='.$good->gid.'&btn=gdesc')}}">修改</a>

                                                 <button class='sta' @if($good->status==2) { disabled } @endif status=2 >下架</button>
                                                    <button class='sta' @if($good->status==3) { disabled } @endif status=3 >特殊</button>
                                               
                                                    
                                                    <button  class='sta' @if($good->status==1) { disabled } @endif  status=1 >上架</button>
                                            </td>
                                        
                                        
                                        </tr>
                                           
                                   

                                        </tbody>
                                </table>
                                    <div class="col-lg-12 " >
                                        <div class="panel panel-primary">
                                            <div class="panel-heading">
                                                商品描述详情
                                            </div>
                                            <div class="panel-body">
                                                <p>{!!$good->gdesc!!}</p>
                                            </div>
                                            <div class="panel-footer">
                                                <a href="{{url('/admin/good/index?num='.$num.'&page='.$page.'&keyword='.$keyword)}}">返回列表页</a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                
        
                                </div>

                            <!-- /.table-responsive -->
                            
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
          
            <!-- /.row -->
           
            <!-- /.row -->
        </div>
 @endsection

 @section('js')
<script type="text/javascript">
    //状态修改处理
        //进行判断
        
        
        //获取按钮
       var sta= $('.sta');
        //获取按钮的
       sta.click(function()
       {

        
        $(this).parent().find('.sta').removeAttr('disabled');
          //获取id
          var id = $(this).parents('tr').find('.sorting_1').html();
          // console.log(id);
          var op = $(this);
          var word = op.html();
         
          // alert(word);
          //获取属性
          var value = op.attr('status');
          //发送ajax
          $.get('/admin/good/status',{gid:id,sta:value},function(data)
          {

           
                if(data)
                {
                    alert('状态修改成功');

                    // op.parents('tr').find('.sa').empty();
                     op.parents('tr').find('.sa').html(word);
                    //进行判断
                    op.attr('disabled','disabled');

                    // alert(a);
                }else{
                    alert('状态修改失败');
                }
          },'json')
       })
    
    
</script>
 @endsection
                      